@import '../../style/themes/index';
@import './mixin.less';
@import './token.less';

@color-picker-prefix-cls: ~'@{kd-prefix}-color-picker';

.@{color-picker-prefix-cls}-container {
  position: relative;
  width: @color-picker-input-sizing-width;
  height: @color-picker-input-sizing-height;

  &-pure {
    width: 28px;

    .@{kd-prefix}-input-wrapper.@{color-picker-prefix-cls}-input {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;

      .@{kd-prefix}-input-prefix {
        margin-right: 0;
      }

      .@{kd-prefix}-input-suffix {
        margin-left: 0;
      }

      .@{kd-prefix}-input {
        display: none;
      }
    }
  }

  .@{color-picker-prefix-cls}-input {
    height: 100%;
    width: 100%;
    padding: 0 8px;
    font-size: @color-picker-input-font-size;
  }

  .@{color-picker-prefix-cls}-icon-container {
    cursor: pointer;

    .@{color-picker-prefix-cls}-icon {
      display: flex;
      justify-content: center;
      align-items: center;
      width: @color-picker-input-prefix-sizing-width;
      height: @color-picker-input-prefix-sizing-height;
      border: 1px solid rgba(0, 0, 0, 0.05);
      border-radius: 2px;
      line-height: 18px;
      text-align: center;
      color: @bg;

      &-no-color-line {
        width: @color-picker-input-prefix-line-sizing-width;
        height: @color-picker-input-prefix-line-sizing-height;
        background-color: #ff2e3d;
        transform: rotate(45deg);
      }
    }
  }
  .@{color-picker-prefix-cls}-icon-container-disabled {
    cursor: not-allowed;
  }
}

.@{color-picker-prefix-cls}-pop {
  width: @color-picker-panel-sizing-width;

  &.topLeft.hidden,
  &.topRight.hidden {
    animation-name: kdSlideDownOut;
  }

  &.topLeft,
  &.topRight {
    animation-name: kdSlideDownIn;
  }

  &.bottomLeft.hidden,
  &.bottomRight.hidden {
    opacity: 0;
    visibility: hidden;
    transition: all calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
    animation-name: kdSlideUpOut;
  }

  &.bottomLeft,
  &.bottomRight {
    animation-name: kdSlideUpIn;
  }

  .@{color-picker-prefix-cls}-panel {
    position: relative;
    box-sizing: border-box;
    width: @color-picker-panel-sizing-width;
    padding: 4px 12px 16px;
    background: #ffffff;
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    transform-origin: top left;
    z-index: @color-picker-panel-z-index;

    & > div {
      margin-top: 12px;
    }

    &-clear {
      display: flex;
      align-items: center;
      font-size: 12px;
      color: #666666;
      line-height: 16px;
      font-weight: 400;

      &-box {
        position: relative;
        width: 16px;
        height: 16px;
        margin-right: 4px;
        border: 1px solid rgba(217, 217, 217, 1);
        border-radius: 2px;
        cursor: pointer;
        background-color: #fff;

        &::after {
          position: absolute;
          left: 7.5px;
          top: -3.5px;
          content: '';
          width: 1px;
          height: 22.6px;
          background-color: #ff2e3d;
          transform: rotate(45deg);
        }

        .active {
          content: '';
          position: absolute;
          top: -3px;
          left: -3px;
          width: 20px;
          height: 20px;
          border: 1px solid rgba(217, 217, 217, 1);
          border-radius: 4px;
        }

        &:hover {
          &::before {
            .active;
          }
        }

        &:active {
          &::before {
            .active;
            border: 1px solid rgba(148, 148, 148, 1);
          }
        }
      }

      &-text {
        font-size: 12px;
        color: #666666;
        line-height: 16px;
        font-weight: 400;
      }
    }

    &-chrome {
      width: 278px !important;
      box-shadow: none !important;

      & > div:last-child {
        padding: 9px 0 4px !important;

        .flexbox-fix:first-child {
          display: flex;
          flex-direction: row-reverse;

          & > div:first-child {
            & > div {
              width: 28px !important;
              height: 28px !important;
              border-radius: 50% !important;
              margin-top: -1px !important;
              margin-left: 4px !important;
            }
          }

          & > div:last-child {
            .hue-horizontal {
              width: 240px !important;
              height: 12px !important;
              border-radius: 6px !important;
              padding: unset !important;

              & > div > div {
                margin-top: 1px;
              }
            }

            & > div:last-child {
              & > div {
                width: 240px !important;
                height: 12px !important;
                margin: unset;

                & > div:first-child {
                  border-radius: 6px !important;
                }

                & > div:nth-child(2) {
                  border-radius: 6px !important;
                }

                & > div:last-child {
                  margin: unset !important;

                  & > div > div {
                    margin-top: 1px;
                  }
                }
              }
            }
          }
        }

        .flexbox-fix:last-child {
          display: none !important;
        }
      }

      &-no-box {
        & > div:first-child {
          display: none;
        }
      }

      &-no-hue {
        & > div:last-child {
          .flexbox-fix:first-child {
            & > div:last-child {
              & > div:first-child {
                display: none;
              }

              & > div:last-child {
                margin-top: 8px;
              }
            }
          }
        }
      }

      &-no-opacity {
        & > div:last-child {
          .flexbox-fix:first-child {
            & > div:last-child {
              & > div:last-child {
                display: none;
              }

              & > div:first-child {
                margin-top: 8px;
              }
            }
          }
        }
      }
    }

    .@{color-picker-prefix-cls}-panel-chrome-no-box.@{color-picker-prefix-cls}-panel-chrome-no-hue.@{color-picker-prefix-cls}-panel-chrome-no-opacity {
      display: none;
    }

    .@{color-picker-prefix-cls}-panel-chrome-no-hue.@{color-picker-prefix-cls}-panel-chrome-no-opacity {
      & > div:last-child {
        display: none;
      }
    }

    &-switch {
      font-size: 12px;
      color: #666666;
      letter-spacing: 0;
      line-height: 16px;
      font-weight: 400;

      span {
        vertical-align: middle;
        margin-right: 9px;
      }
    }

    &-container {
      display: flex;
      flex-wrap: nowrap;

      &-select {
        flex: 0 0 64px;
        display: inline-block;
        position: relative;
        margin-right: 8px;
        font-size: @color-picker-panel-select-font-size;

        .@{kd-prefix}-select {
          width: 64px;

          .@{kd-prefix}-select,
          .@{kd-prefix}-select-selection-item {
            min-height: unset;
            line-height: unset;
            overflow: visible;
            text-overflow: unset;
          }

          &-suffix {
            padding-right: 4px;
            margin-left: 0;
          }
        }

        .@{kd-prefix}-select-dropdown-panel {
          margin: 0 !important;

          &.bottomLeft,
          &.topLeft {
            position: absolute;
            width: 64px !important;
            min-width: unset !important;
            background: #ffffff;
            right: 0;
            left: unset !important;
            box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2);
            border-radius: 2px;
          }

          .@{kd-prefix}-select-dropdown {
            .@{kd-prefix}-select-item-option {
              display: flex;
              justify-content: center;
              min-width: unset;
            }
          }
        }

        .@{kd-prefix}-select-bordered {
          border-radius: 2px;
          width: @color-picker-panel-select-sizing-width;
          height: @color-picker-panel-select-sizing-height;
          min-height: 28px;
          padding: 0 28px 0 0;
        }

        .active-option {
          background-color: @color-picker-panel-option-color-background;
        }
      }

      &-input {
        height: 28px;
        flex: 1 1 auto;
        padding: 0 8px;
      }

      &-input-group {
        display: flex;
        align-items: center;

        &-item {
          height: 28px;
          flex: 1;

          &.active {
            z-index: 2;
          }

          &:first-child {
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            z-index: 1;
          }

          &:nth-child(2) {
            margin-right: -1px;
            margin-left: -1px;
            border-radius: 0;

            &:hover {
              z-index: 1;
            }
          }

          &:last-child {
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
          }
        }
      }

      &-transparent {
        flex: 0 0 54px;
        height: 28px;
        margin-left: 8px;
        padding: 0;
        text-align: center;
        font-size: @color-picker-panel-alpha-font-size;
      }
    }

    &-historical-color-box {
      &-title {
        font-size: 12px;
        color: #666666;
        line-height: 18px;
        font-weight: 400;
        margin-bottom: 8px;
      }

      &-container {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        grid-column-gap: 8px;
        grid-row-gap: 8px;

        &-ie11 {
          display: flex;
          flex-wrap: wrap;

          li {
            margin-right: 8px;
            margin-top: 8px;

            &:nth-child(12n) {
              margin-right: 0;
            }

            &:nth-child(-n + 12) {
              margin-top: 0;
            }
          }
        }

        li {
          position: relative;
          box-sizing: border-box;
          width: @color-picker-panel-historical-sizing-width;
          height: @color-picker-panel-historical-sizing-height;
          border: 1px solid rgba(0, 0, 0, 0.05);
          border-radius: 2px;
          list-style: none;
          cursor: pointer;

          .square {
            display: none;
            position: absolute;
            box-sizing: inherit;
            top: -3px;
            left: -3px;
            width: calc(@color-picker-panel-historical-sizing-width + 4px);
            height: calc(@color-picker-panel-historical-sizing-height + 4px);
            border: 1px solid rgba(178, 178, 176, 1);
            border-radius: 4px;

            &-click {
              display: block;
              box-shadow: 0 0 0 1px #e5e5e5 !important;
            }
          }

          &:hover {
            .square {
              display: block;
            }
          }
        }
      }
    }

    &-color-box {
      &-title {
        font-size: 12px;
        color: #666666;
        line-height: 18px;
        font-weight: 400;
        margin-bottom: 8px;
      }

      &-container {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        grid-column-gap: 8px;
        grid-row-gap: 8px;

        &-ie11 {
          display: flex;
          flex-wrap: wrap;

          li {
            margin-right: 8px;
            margin-top: 8px;

            &:nth-child(12n) {
              margin-right: 0;
            }

            &:nth-child(-n + 12) {
              margin-top: 0;
            }
          }
        }

        li {
          position: relative;
          box-sizing: border-box;
          width: @color-picker-panel-preset-sizing-width;
          height: @color-picker-panel-preset-sizing-height;
          border: 1px solid rgba(0, 0, 0, 0.05);
          border-radius: 2px;
          list-style: none;
          cursor: pointer;

          .square {
            display: none;
            position: absolute;
            box-sizing: inherit;
            top: -3px;
            left: -3px;
            width: calc(@color-picker-panel-preset-sizing-width + 4px);
            height: calc(@color-picker-panel-preset-sizing-height + 4px);
            border: 1px solid rgba(178, 178, 176, 1);
            border-radius: 4px;

            &-click {
              display: block;
              box-shadow: 0 0 0 1px #e5e5e5 !important;
            }
          }

          &:hover {
            .square {
              display: block;
            }
          }
        }
      }
    }
  }
}

.@{color-picker-prefix-cls}-rtl {
  direction: rtl;
  .@{color-picker-prefix-cls}-input {
    .@{kd-prefix}-input-prefix {
      margin-right: 0;
      margin-left: 3px;
    }
    .@{kd-prefix}-input {
      direction: ltr;
      text-align: right;
    }
  }
  &.@{color-picker-prefix-cls}-pop {
    .@{color-picker-prefix-cls}-panel {
      transform-origin: top left;
      &-clear {
        &-box {
          margin-left: 4px;
          margin-right: 0;
        }
      }
      &-switch {
        span {
          margin-right: 9px;
          margin-left: 0;
        }
      }

      &-container {
        &-select {
          margin-left: 8px;
          margin-right: 0;
          .@{kd-prefix}-select-bordered {
            padding: 0 28px 0 0;
          }
        }
        &-input {
          direction: ltr;
          text-align: right;
        }

        &-input-group {
          display: flex;
          align-items: center;

          &-item {
            height: 28px;
            flex: 1;

            &.active {
              z-index: 2;
            }

            &:first-child {
              border-top-right-radius: 0;
              border-bottom-right-radius: 0;
              z-index: 1;
            }

            &:nth-child(2) {
              margin-right: -1px;
              margin-left: -1px;
              border-radius: 0;

              &:hover {
                z-index: 1;
              }
            }

            &:last-child {
              border-top-left-radius: 0;
              border-bottom-left-radius: 0;
            }
          }
        }

        &-transparent {
          flex: 0 0 54px;
          height: 28px;
          margin-right: 8px;
          margin-left: 0;
          padding: 0;
          text-align: center;
          font-size: @color-picker-panel-alpha-font-size;
        }
      }

      &-historical-color-box {
        &-title {
          font-size: 12px;
          color: #666666;
          line-height: 18px;
          font-weight: 400;
          margin-bottom: 8px;
        }

        &-container {
          display: grid;
          grid-template-columns: repeat(12, 1fr);
          grid-column-gap: 8px;
          grid-row-gap: 8px;

          &-ie11 {
            display: flex;
            flex-wrap: wrap;

            li {
              margin-right: 8px;
              margin-top: 8px;

              &:nth-child(12n) {
                margin-right: 0;
              }

              &:nth-child(-n + 12) {
                margin-top: 0;
              }
            }
          }
        }
      }
    }
  }
  .@{color-picker-prefix-cls}-panel {
    &-chrome {
      & > div:last-child {
        .flexbox-fix:first-child {
          & > div:first-child {
            & > div {
              margin-right: 4px !important;
              margin-left: 0 !important;
            }
          }
        }
      }
    }
  }
}
